#include "ground.h"

using namespace std;

uint64 Ground::owner_id2() const { return owner_id2_; }

uint64 Ground::owner_id1() const { return owner_id1_; }

uint8 Ground::bait_state() const { return r1(ptr() + 0x14C) & 0xF; }

float Ground::x() const { return x_; }

float Ground::y() const { return y_; }

float Ground::z() const { return z_; }

const std::string &Ground::name() const { return name_; }

uint64 Ground::ptr() const { return obj_.ptr(); }

ObjType Ground::type() const { return obj_.type(); }

uint32 Ground::index() const { return obj_.index(); }

uint64 Ground::id1() const { return obj_.id1(); }

uint64 Ground::id2() const { return obj_.id2(); }

// --- Constructors ---

Ground::Ground(uint64 ptr) : obj_{ptr} {
  x_ = rfloat(ptr + 0x130);
  y_ = rfloat(ptr + 0x134);
  z_ = rfloat(ptr + 0x138);
  // if (!IsBadReadPtr((void *)(ptr + 0x128), 8)) {
  //   if (!(IsBadReadPtr((void *)(r8(ptr + 0x128) + 0xE0), 8))) {
  //     name_ = (char *)r8(r8(ptr + 0x128) + 0xE0);
  //   }
  // }
  name_ = (char *)r8(r8(ptr + 0x128) + 0xE0);
  owner_id1_ = r8(ptr + 0x1B0);
  owner_id2_ = r8(ptr + 0x1B8);
}

Ground::~Ground() {}
